
// 内丹升级 {"召唤兽":1,"内丹":19}

// @ts-ignore
export function execute(client_id, message_json) {
    let characters = G.Characters.get_current_login_characters(client_id);
    let pet_index = message_json["召唤兽"] - 1;
    let item_index = message_json["内丹"] - 1;
    let pet_data = characters["召唤兽"][pet_index];
    if (pet_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "召唤兽不存在");
        return;
    }
    if (pet_data["参战信息"] === 1) {
        ClientUtils.send_basic_prompt(client_id, "请先取消召唤兽的参战状态");
        return;
    }
    let item = characters["道具"][item_index];
    if (!item) {
        ClientUtils.send_basic_prompt(client_id, "#背包内不存在物品");
        return;
    }
    if (item["总类"] !== 203) {
        ClientUtils.send_basic_prompt(client_id, "#请选择召唤兽内丹");
        return;
    }
    for (let index = 0; index < pet_data["内丹"]["数据"].length; index++) {
        let element = pet_data["内丹"]["数据"][index];
        if (element["技能"] === item["特效"]) {
            if (element["等级"] < 5) {
                element["等级"] += 1;
                G.Characters.remove_item(characters["id"], "道具", item_index, 1);
                ClientUtils.send_basic_prompt(client_id, `恭喜, 你的${pet_data["名称"]}#Y的内丹技能#R/${item["特效"]}#Y达到${element["等级"]}级。`);
                //刷新召唤兽列表
                // ClientUtils.send_client_message(client_id, 16, characters["召唤兽"]);
                //通知客户端刷新道具数据
                G.Characters.refrush_item_data(characters["id"], ["道具"]);
                ClientUtils.send_client_message(client_id, 16, characters["召唤兽"]);
                // 刷新内丹
                ClientUtils.send_client_message(client_id, 102, { "序号": pet_index + 1, "内丹": pet_data["内丹"] });
            } else {
                ClientUtils.send_basic_prompt(client_id, "该内丹层数已达上限！");
            }
            return;
        }
    }
    ClientUtils.send_basic_prompt(client_id, "与已学习的内丹技能不一致，无法提升等级");
    //通知客户端刷新道具数据
    G.Characters.refrush_item_data(characters["id"], ["道具"]);
}